import { request } from './axios-config'

// const BASE_URL = process.env.VUE_APP_API_URL;
const URL = "/umale-acceptance-web";

/**
 * 根据身份证号或者单位信用代码查询处罚记录
 */
export function historyPublish({
  code = null, //执法对象个人身份证号或者单位名称信用码
  type = null, //1为个人对象 2为单位对象
}) {
  return request({
    url: `${URL}/entryEvent/historyPublish/findAll`,
    method: 'GET',
    params: {
      code,
      type
    }
  })
}

/**
 * 下派
 */
export function saveBySubordinate(data) {
  return request({
    url: `${URL}/entryEvent/saveBySubordinate`,
    method: 'POST',
    data
  })
}

/**
 * 上报
 */
export function insertEvent(data) {
  return request({
    url: `${URL}/entryEvent/insertEvent`,
    method: 'POST',
    data
  })
}

/**
 * 所属区县,所属街道
 * @param {String} parentCode 不传为查询所有一级，其它为所属街道
 */
export function findArea(parentCode = "") {
  return request({
    url: `${URL}/common/area/findAll`,
    method: 'GET',
    params: {
      parentCode
    }
  })
}

/**
 * 分页查询所有待处理事件
 */
export function getAllProcessList(data) {
  return request({
    url: `${URL}/event/process/pages/userId/${data.userId}/userLevel/${data.userLevel}`,
    method: 'POST',
    data
  })
}

/**
 * 事件退回
 * POST /handleEvent/sendBack
 */
export function sendBack(data) {
  return request({
    url: `${URL}/handleEvent/sendBack`,
    method: 'POST',
    data
  })
}
/**
 * 无发现
 * POST /event/process/noFound
 */
export function noFoundApi(data) {
  return request({
    url: `${URL}/event/process/noFound`,
    method: 'POST',
    data
  })
}
/**
 * 教育劝改
 * POST /event/process/advised
 */
export function advised(data) {
  return request({
    url: `${URL}/event/process/advised`,
    method: 'POST',
    data
  })
}

/**
 * 责令改正
 * POST /event/process/correction
 */
export function correction(data) {
  return request({
    url: `${URL}/event/process/correction`,
    method: 'POST',
    data
  })
}

/**
 * 事件详情
 * GET /event/list/findOne/{eventId}
 */
export function findOne({
  eventId = "",
  userId = ""
}) {
  return request({
    url: `${URL}/event/list/findOne/${eventId}/${userId}`,
    method: 'GET',
  })
}

/**
 * 查看更多记录
 * GET /handleEvent/moreEvents/{eventId}
 */
export function moreEvents(eventId = "") {
  return request({
    url: `${URL}/handleEvent/moreEvents/${eventId}`,
    method: 'GET',
  })
}

/**
 * 事件受理列表
 * POST /eventAssignment/assignments/{userId}/{userLevel}
 */
export function getAllDispatchList(data) {
  return request({
    url: `${URL}/eventAssignment/assignments/${data.groupId}/${data.userLevel}`,
    method: 'POST',
    data
  })
}

/**
 * 结案
 * POST /event/approval/endCase
 */
export function endCase(data) {
  return request({
    url: `${URL}/event/approval/endCase`,
    method: 'POST',
    data
  })
}

/**
 * 结案列表
 * POST /event/approval/findAll
 */
export function endCaseList(data) {
  return request({
    url: `${URL}/event/approval/findAll`,
    method: 'POST',
    data
  })
}

/**
 * 结案退回
 * POST /event/approval/findAll
 */
export function sendBackEnd(data) {
  return request({
    url: `${URL}/event/approval/sendBack`,
    method: 'POST',
    data
  })
}

/**
 * 结案改派
 * POST /event/approval/updateSubordinate
 */
export function updateSubordinate(data) {
  return request({
    url: `${URL}/event/approval/updateSubordinate`,
    method: 'POST',
    data
  })
}

/**
 * 反馈详情
 * GET /event/approval/findFeedBack/{eventId}
 */
export function findFeedBack(eventId) {
  return request({
    url: `${URL}/event/approval/findFeedBack/${eventId}`,
    method: 'GET'
  })
}

/**
 * 事件详情之处理结果
 * GET /event/list/findOneResult/{eventId}
 */
export function findOneResult(eventId = "") {
  return request({
    url: `${URL}/event/list/findOneResult/${eventId}`,
    method: 'GET',
  })
}

/**
 * 事件列表(经办事件和所有事件)
 */
export function getAllEventList(data) {
  return request({
    url: `${URL}/event/list/findAll`,
    method: 'POST',
    data
  })
}

/**
 * 事件反馈
 * POST /handleEvent/feedBack
 */
export function handleFeedBack({
  assigner,
  eventId,
  groupId,
  message,
  url,
  userId,
  userName,
  userOrgId,
  userOrgName
}) {
  return request({
    url: `${URL}/handleEvent/feedBack`,
    method: 'POST',
    data: {
      assigner,
      eventId,
      groupId,
      message,
      url,
      userId,
      userName,
      userOrgId,
      userOrgName
    }
  })
}

/**
 * 事件不予受理
 * POST /handleEvent/inadmissible
 */
export function inadmissibleApi({
  assigner, // 所在组织级别
  eventId, // 事件Id
  groupId, // 当前用户ID
  userName,
  message, // 具体的情况说明
  userId, // 用户id
  userOrgId, // 用户组织id
  userOrgName, // 所在组织名
}) {
  return request({
    url: `${URL}/handleEvent/inadmissible`,
    method: 'POST',
    data: {
      assigner, // 所在组织级别
      eventId, // 事件Id
      groupId, // 当前用户ID
      userName,
      message, // 具体的情况说明
      userId, // 用户id
      userOrgId, // 用户组织id
      userOrgName, // 所在组织名
    }
  })
}

/**
 * 事件下派对象获取当前用户下个层级的人员
 * GET /common/object/findAll/{groupId}/{orgLevel}
 * @param {String} groupId 当前用户组织id
 * @param {String} orgLevel 当前用户等级
 */
export function findAllObject({
  orgLevel = "",
  groupId = ""
}) {
  return request({
    url: `${URL}/common/object/findAll/${groupId}/${orgLevel}`,
    method: 'GET'
  })
}

// 通过区局的id查询该区局下所有人员
export function getOrgStaffList(groupId, roleId = null) {
  return request({
    url: `/umale-maintenance-web/common/api/users/${groupId}/role/${roleId}`,
    method: 'GET'
  })
}

// ********违停接口********

// 验证登录是否有效
export function authUser(localUser) {
  return request({
    url: `${URL}/illegal/park/check_login?localUser=${localUser}`,
    method: 'GET'
  })
}
// 重新登录
export function login(serverUser, pwd, localUser) {
  return request({
    url: `${URL}/illegal/park/login?serverUser=${serverUser}&pwd=${pwd}&localUser=${localUser}`,
    method: 'GET'
  })
}
// 获取承办人
export function get_users(userCode, sessionKey, sessionId) {
  return request({
    url: `${URL}/illegal/park/get_users?userCode=${userCode}&sessionKey=${sessionKey}&sessionId=${sessionId}`,
    method: 'GET'
  })
}
// 获取道路
export function get_roads(userCode, sessionKey, sessionId) {
  return request({
    url: `${URL}/illegal/park/get_roads?userCode=${userCode}&sessionKey=${sessionKey}&sessionId=${sessionId}`,
    method: 'GET'
  })
}

export function add_case(data, imgs) {
  return request({
    url: `${URL}/illegal/park/add_case?localUserCode=${data.localUserCode}&serverUserCode=${data.serverUserCode}&illegalTime=${data.illegalTime}&illegal=${data.illegal}&informBill=${data.informBill}&agentMainId=${data.agentMainId}&agentMainName=${data.agentMainName}&agentLesserId=${data.agentLesserId}&agentLesserName=${data.agentLesserName}&roadCode=${data.roadCode}&road=${data.road}&address=${data.address}&caseStatus=${data.caseStatus}&isBlind=${data.isBlind}&flag=${data.flag}&note=${data.note}&isSend=${data.isSend}&plateType=${data.plateType}&licensePlate=${data.licensePlate}&sessionKey=${data.sessionKey}&sessionId=${data.sessionId}`,
    method: 'POST',
    data: imgs,
    headers: {
      "Content-Type": "multipart/form-data",
      "Access-Control-Allow-Origin": "*",
      "Access-Control-Allow-Credentials": true,
      "Access-Control-Allow-Headers": "*",
      "Access-Control-Allow-Methods": "*"
    }
  })
}

// 判断是否被处理过 中队
export function judgeHandle(eventId, userId, userLevel) {
  return request({
    url: `${URL}/event/process/judgeEvent/event/${eventId}/userId/${userId}/userLevel/${userLevel}`,
    method: 'GET',
  })
}